package com.monkeys.controller;


import com.monkeys.pojo.Result;
import com.monkeys.pojo.Vehicle;
import com.monkeys.service.VehicleService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;


/**
 * @author KuangTeam
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/vehicle")
public class VehicleController {

    private final VehicleService vehicleService;

    //创建随机参数的一辆待运的货车
    @GetMapping("/create")
    public Result<Vehicle> createVehicle(){
        Vehicle vehicle = vehicleService.createVehicle();
        return Result.success(vehicle);
    }


    //创建任意辆待运的货车
    @GetMapping("/create/{id}")
    public Result<List<Vehicle>> createVehicles(@PathVariable Long id){
        List<Vehicle> vehicleList = vehicleService.createVehicles(id);
        return Result.success(vehicleList);
    }


    //更新车辆数据
    @PutMapping("/update")
    public Result<Object> updateVehicle(@RequestBody Vehicle vehicle){
        vehicleService.update(vehicle);
        return Result.success();
    }

}
